﻿@using Lari.Configuration
@using Lari.Web.Utility
@model Lari.Services.ViewModel.EmployeeModel
@{
    var title = Model.ID == 0 ? ScreenName.Users.NewEmployee : ScreenName.Users.EditEmployee;
    var post = Model.ID == 0 ? ActionConst.Users.AddEmployee : ActionConst.Users.EditEmployee;
    var submit = Model.ID == 0 ? GuiActionName.Save : GuiActionName.Update;
}
<div id="pagetitle">
    <h1>@title</h1>
</div>
<div class="spacer">
</div>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken("addnewemployee")
    <div id="pagecontent">
        <table width="100%">
            <tr>
                <td width="50%" style="vertical-align: top">
                    <fieldset>
                        <legend>General Details</legend>
                        <table width="100%">
                            @if (Model.ID != 0)
                            {
                                <tr>
                                    <td colspan="1">
                                        <div>
                                            <label>
                                                Employee #:
                                            </label>@Model.ID</div>
                                        @Html.HiddenFor(m => m.ID)
                                    </td>
                                    <td colspan="4">
                                        &nbsp;
                                    </td>
                                </tr>   
                            }
                            <tr>
                                <td colspan="1">
                                    <div>
                                        <label class="required">
                                            Title</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.Title, this.ToListItems(LookupEnum.Title), new { style = "width: 100%" })
                                    </div>
                                    <div>
                                        @Html.ValidationMessageFor(m => m.Title)</div>
                                </td>
                                <td colspan="4">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            First Name</label></div>
                                    <div>
                                        @Html.TextBoxFor(m => m.FirstName)
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.FirstName)</div>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Middle Name</label></div>
                                    <div>
                                        @Html.TextBoxFor(m => m.Middlename)
                                    </div>
                                    <div>
                                        @Html.ValidationMessageFor(m => m.Middlename)</div>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label class="required">
                                            Last Name</label></div>
                                    <div>
                                        @Html.TextBoxFor(m => m.LastName)
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.LastName)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            DOB</label><label style="font-size: 10px">
                                                (dd-mm-yyyy format)</label></div>
                                    <div>@Html.EditorFor(m => m.DOB)</div>
                                    @*<div>@Html.TextBoxFor(m => m.DOB, new { @class = "datePickerBox", style = "width: 75%" })</div>*@
                                    <div>@Html.ValidationMessageFor(m => m.DOB)</div>
                                </td>
                                <td>
                                    <div>
                                        &nbsp;</div>
                                    <div>
                                        <strong>Or</strong>
                                    </div>
                                </td>
                                <td colspan="3">
                                    <div>
                                        <label>
                                            Age</label><label style="font-size: 10px">
                                                (in Yrs.)</label></div>
                                    <div>@Html.TextBoxFor(m => m.Age, new { style = "width: 33%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.Age)</div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <div>
                                        <label class="required">
                                            Gender</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.GenderCode, this.ToListItems(LookupEnum.Gender), new { style = "width: 100%" })
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.GenderCode)</div>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td colspan="1">
                                    <div>
                                        <label class="required">
                                            Marital Status</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.MaritalStatusCode, this.ToListItems(LookupEnum.MaritalStatus), new { style = "width: 100%" })
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.MaritalStatusCode)</div>
                                </td>
                                <td colspan="2">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <div>
                                        <label>
                                            Religion</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.ReligionCode, this.ToListItems(LookupEnum.Religion), new { style = "width: 100%" })
                                    </div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label class="required">
                                            Nationality</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.NationalityCode, this.ToListItems(LookupEnum.Country), new { style = "width: 100%" })
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.NationalityCode)</div>
                                </td>
                                <td colspan="2">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            Bloodgroup</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.BloodGpId, this.ToListItems(LookupEnum.Bloodgroup), new { style = "width: 100%" })
                                    </div>
                                </td>
                                <td colspan="4">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            Department</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.DepartmentId, this.ToListItems(LookupEnum.Department), new { style = "width: 100%", @id = "drpDepartment" })
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.DepartmentId)</div>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Designation</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.DesignationId, this.ToListItems(LookupEnum.Designation, dependentID: Model.DepartmentId), new { style = "width: 100%", @id = "drpDesignation" })
                                        @* @Html.TextBoxFor(m => m.DesignationId,new{@id="hidDesignation"})*@
                                    </div>
                                </td>
                                <td colspan="2">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            Mobile #</label></div>
                                    <div>
                                        @Html.TextBoxFor(m => m.Mobile)
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.Mobile)</div>
                                </td>
                                <td colspan="4">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            Email</label></div>
                                    <div>
                                        @Html.TextBoxFor(m => m.Email)
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.Email)</div>
                                </td>
                                <td colspan="4">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            Type</label></div>
                                    <div>
                                        @Html.DropDownListFor(m => m.EmployeeType, this.ToListItems(LookupEnum.EmploypeeType), new { style = "width: 100%" })
                                    </div>
                                    <div>@Html.ValidationMessageFor(m => m.EmployeeType)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label class="required">
                                            Is Consultant</label></div>
                                    <div>
                                        @Html.CheckBoxFor(m => m.IsConsultant)
                                    </div>
                                </td>
                                <td colspan="2">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
                <td width="50%" style="vertical-align: top">
                    <fieldset>
                        <legend>Home Address</legend>
                        <table>
                            <tr>
                                <td colspan="3">
                                    <div>
                                        <label class="required">
                                            Addess</label></div>
                                    <div>@Html.TextAreaFor(m => m.HomeAddress, new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomeAddress)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            City</label></div>
                                    <div>@Html.TextBoxFor(m => m.HomeCity)</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomeCity)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Phone</label></div>
                                    <div>@Html.TextBoxFor(m => m.HomePhone)</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomePhone)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            State</label></div>
                                    <div>@Html.DropDownListFor(m => m.HomeStateCode, this.ToListItems(LookupEnum.State), new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomeStateCode)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            State</label><label style="font-size: 10px">
                                                (Other)</label></div>
                                    <div>@Html.TextBoxFor(m => m.HomeStateOther)</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomeStateOther)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            Country</label></div>
                                    <div>@Html.DropDownListFor(m => m.HomeCountryCode, this.ToListItems(LookupEnum.Country), new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomeCountryCode)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Zip Code</label></div>
                                    <div>@Html.TextBoxFor(m => m.HomePinCode)</div>
                                    <div>@Html.ValidationMessageFor(m => m.HomePinCode)</div>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                    <div class="spacer">
                    </div>
                    <fieldset>
                        <legend>Work Address</legend>
                        <table>
                            <tr>
                                <td colspan="3">
                                    <div>
                                        <label class="required">
                                            Addess</label></div>
                                    <div>@Html.TextAreaFor(m => m.WorkAddress, new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkAddress)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            City</label></div>
                                    <div>@Html.TextBoxFor(m => m.WorkCity)</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkCity)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Phone</label></div>
                                    <div>@Html.TextBoxFor(m => m.WorkPhone)</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkPhone)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label>
                                            State</label></div>
                                    <div>@Html.DropDownListFor(m => m.WorkStateCode, this.ToListItems(LookupEnum.State), new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkStateCode)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            State</label><label style="font-size: 10px">
                                                (Other)</label></div>
                                    <div>@Html.TextBoxFor(m => m.WorkStateOther)</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkStateOther)</div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <label class="required">
                                            Country</label></div>
                                    <div>@Html.DropDownListFor(m => m.WorkCountryCode, this.ToListItems(LookupEnum.Country), new { style = "width: 100%" })</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkCountryCode)</div>
                                </td>
                                <td colspan="1">
                                    &nbsp;
                                </td>
                                <td>
                                    <div>
                                        <label>
                                            Zip Code</label></div>
                                    <div>@Html.TextBoxFor(m => m.WorkPinCode)</div>
                                    <div>@Html.ValidationMessageFor(m => m.WorkPinCode)</div>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
        </table>
        <div style="float: right">
            <input id="btnSave" type="submit" value="@submit"/>
        </div>
        @if (Model.ID > 0)
        {
            <div style="float: left">
                <div>@Html.ActionLink("Back to Employee Details", ActionConst.Users.ViewEmployee, new { id = Model.ID })</div>
            </div>

        }
        <div class="clear">
        </div>
    </div>
}
<script type="text/javascript">

    $(document).ready(function () {
        $("#btnSave").button();

        $.datepicker.setDefaults({
            dateFormat: 'dd-mm-yy'
        });


        $(".datePickerBox").datepicker({
            changeMonth: true,
            changeYear: true,
            showOn: "button",
            buttonImageOnly: false

        });

        $("#drpDepartment").change(function () {

            var dropdownval = $("#drpDepartment").val();
            var selectDesignation = $('#drpDesignation');

            selectDesignation.empty();
            selectDesignation.append($('<option/>', { value: '' }).html(''));
            $("#hidDesignation").val('');

            $.getJSON('@Url.Action(ActionConst.Masters.Common.GetDesignation, ControllerConst.Masters.CoreMaster)', { id: dropdownval }, function (result) {

                $(result).each(function () {
                    selectDesignation.append($('<option/>', { value: this.Value }).html(this.Text));
                });

            });


        });





    });
    
</script>
